class Session {
    constructor() {
        this.appid = '';
        this.userInfo = {
            sessionId: null,
            openid: null,
            uid: null,
            unionid: null,
            nickName: null,
            avatarUrl: null,
            gender: null,
            country: null,
            city: null,
            province: null,
            language: null,
        };
    }

    setAppid(appid) {
        this.appid = appid;
    }

    getAppid() {
        return this.appid;
    }

    setSession(data) {
        this.appid = data?.appid;
        this.userInfo.sessionId = data.session_id;
        this.userInfo.openid = data.openid;
        this.userInfo.uid = data.uid;
        this.userInfo.unionid = data.unionid;
    }

    updateSession(data) {
        this.setSession(data);
    }

    getSession() {
        return this.userInfo;
    }
}

let session = new Session();

export default session;
